<template>
  <div class="login-container">
    <div class="login-background">
      <div class="login-overlay"></div>
    </div>
    
    <div class="login-content">
      <div class="login-left">
        <div class="welcome-container">
          <div class="logo">
            <span>AI</span>
          </div>
          <h1 class="welcome-title">欢迎使用AI教学系统</h1>
          <p class="welcome-subtitle">智能化教学管理平台，助力教育数字化转型</p>
          <div class="features">
            <div class="feature-item">
              <el-icon><video-camera /></el-icon>
              <span>PPT智能转视频</span>
            </div>
            <div class="feature-item">
              <el-icon><document /></el-icon>
              <span>一键生成PPT</span>
            </div>
            <div class="feature-item">
              <el-icon><question-filled /></el-icon>
              <span>智能出题系统</span>
            </div>
          </div>
        </div>
      </div>
      
      <div class="login-right">
        <div class="login-card">
          <div class="login-header">
            <h2>账号登录</h2>
            <p>请输入您的账号信息</p>
          </div>
          
          <el-form :model="loginForm" :rules="rules" ref="loginFormRef">
            <el-form-item prop="username">
              <el-input 
                v-model="loginForm.username" 
                placeholder="用户名/邮箱"
                size="large"
              >
                <template #prefix>
                  <el-icon><User /></el-icon>
                </template>
              </el-input>
            </el-form-item>
            
            <el-form-item prop="password">
              <el-input 
                v-model="loginForm.password" 
                type="password" 
                placeholder="密码"
                size="large"
                show-password
              >
                <template #prefix>
                  <el-icon><Lock /></el-icon>
                </template>
              </el-input>
            </el-form-item>
            
            <div class="login-options">
              <el-checkbox v-model="rememberMe">记住我</el-checkbox>
              <a href="#" class="forgot-password">忘记密码?</a>
            </div>
            
            <el-form-item>
              <el-button 
                type="primary" 
                @click="handleLogin" 
                class="login-btn"
                size="large"
              >
                登录
              </el-button>
            </el-form-item>
            
            <div class="divider">
              <span>或使用其他方式登录</span>
            </div>
            
            <div class="social-login">
              <el-button class="social-btn" circle>
                <el-icon><iphone /></el-icon>
              </el-button>
              <el-button class="social-btn" circle>
                <el-icon><picture /></el-icon>
              </el-button>
              <el-button class="social-btn" circle>
                <el-icon><connection /></el-icon>
              </el-button>
            </div>
          </el-form>
          
          <div class="register-link">
            还没有账号? <a href="#">立即注册</a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { 
  User, 
  Lock, 
  VideoCamera, 
  Document, 
  QuestionFilled,
  Iphone,
  Picture,
  Connection
} from '@element-plus/icons-vue'

const router = useRouter()
const loginFormRef = ref()
const rememberMe = ref(false)

const loginForm = reactive({
  username: '',
  password: ''
})

const rules = {
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' },
    { min: 3, message: '用户名长度至少为3个字符', trigger: 'blur' }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'blur' },
    { min: 6, message: '密码长度至少为6个字符', trigger: 'blur' }
  ]
}

const handleLogin = async () => {
  if (!loginFormRef.value) return
  await loginFormRef.value.validate((valid: boolean) => {
    if (valid) {
      // TODO: 实现登录逻辑
      router.push('/')
    }
  })
}
</script>

<style scoped>
.login-container {
  height: 100vh;
  display: flex;
  position: relative;
  overflow: hidden;
}

.login-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  z-index: 0;
}

.login-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('https://images.unsplash.com/photo-1501504905252-473c47e087f8?q=80&w=1974&auto=format&fit=crop') center/cover no-repeat;
  opacity: 0.2;
}

.login-content {
  display: flex;
  width: 100%;
  max-width: 1200px;
  margin: auto;
  z-index: 1;
  position: relative;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-body);
}

.login-left {
  flex: 1;
  padding: var(--space-xl);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-right {
  flex: 1;
  padding: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-container {
  max-width: 500px;
}

.logo {
  width: 80px;
  height: 80px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-lg);
  font-size: 36px;
  font-weight: bold;
}

.welcome-title {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.welcome-subtitle {
  font-size: 18px;
  opacity: 0.9;
  margin-bottom: var(--space-lg);
}

.features {
  margin-top: var(--space-xl);
}

.feature-item {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-md);
  font-size: 18px;
}

.feature-item .el-icon {
  font-size: 24px;
  margin-right: var(--space-sm);
}

.login-card {
  width: 100%;
  max-width: 450px;
  padding: var(--space-xl);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-header h2 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.login-header p {
  color: var(--text-secondary);
  font-size: 16px;
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.forgot-password {
  color: var(--primary);
  text-decoration: none;
  font-size: 14px;
  transition: var(--transition);
}

.forgot-password:hover {
  text-decoration: underline;
}

.login-btn {
  width: 100%;
  padding: 15px;
  font-size: 16px;
  font-weight: 500;
  margin-top: var(--space-md);
}

.divider {
  display: flex;
  align-items: center;
  margin: var(--space-xl) 0;
  color: var(--text-secondary);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.divider span {
  padding: 0 var(--space-md);
  font-size: 14px;
}

.social-login {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.social-btn {
  width: 48px;
  height: 48px;
  font-size: 20px;
  border: 1px solid var(--border-color);
  background: transparent;
  transition: var(--transition);
}

.social-btn:hover {
  background: var(--gray-100);
  transform: translateY(-3px);
}

.register-link {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.register-link a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  margin-left: var(--space-xs);
  transition: var(--transition);
}

.register-link a:hover {
  text-decoration: underline;
}

/* 响应式设计 */
@media screen and (max-width: 900px) {
  .login-left {
    display: none;
  }
  
  .login-right {
    padding: var(--space-lg);
  }
  
  .login-card {
    padding: var(--space-lg);
  }
}
</style>
